//
// Created by 86155 on 2025/4/16.
//

#ifndef LLVM_FEREGISTERINFO_H
#define LLVM_FEREGISTERINFO_H

#include "llvm/CodeGen/TargetRegisterInfo.h"

#define GET_REGINFO_HEADER
#include "FeGenRegisterInfo.inc"

namespace llvm {
class FeSubtarget;
class FeRegisterInfo : public FeGenRegisterInfo {
  const FeSubtarget &STI;
public:
  FeRegisterInfo(const FeSubtarget &STI);

  const MCPhysReg *getCalleeSavedRegs(const MachineFunction *MF) const override;//被调用函数保存寄存器

  BitVector getReservedRegs(const MachineFunction &MF) const override;//保留寄存器 不参与寄存器分配
  //发射帧index 栈帧 -》 寄存器的偏移
  bool eliminateFrameIndex(MachineBasicBlock::iterator MI, int SPAdj,
                           unsigned FIOperandNum,
                           RegScavenger *RS = nullptr) const override;

  Register getFrameRegister(const MachineFunction &MF) const override;//帧寄存器

  const uint32_t *getCallPreservedMask(const MachineFunction &MF, CallingConv::ID) const override;

};

}


#endif // LLVM_FEREGISTERINFO_H
